<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <a id="btn">跳转</a>
    <input type="file" id="input">
    <script>
        var str = `
        <div>
            <div>
                <p>123</p>
                </div>
            </div>
        `
        var blob = new Blob([str], {
            type: 'text/html'
        })
        btn.onclick = function (e) {
            this.setAttribute('download', '123.html')
            this.href = URL.createObjectURL(blob)
        }
        input.onchange = function (e) {
            var file = e.target.files[0]
            // var a = document.createElement('a')
            // a.setAttribute('download', 'myBaidu.html')
            // this.href = URL.createObjectURL(blob)
            // a.click()

            var img=new Image()
            img.src=URL.createObjectURL(file)
            document.body.appendChild(img)
        }
        console.log(blob)
    </script>
</body>

</html>